﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Project02
{
    class Object
    {
        GraphicsDevice graphicDevice;

        private Texture2D objTexture;
        public Texture2D ObjTexture
        {
            get { return objTexture; }
            set { objTexture = value; }
        }
        private Vector2 dimension;
        public Vector2 Dimension
        {
            get {return  dimension;}
            set { dimension = value;}
        }

        private int mass;
        public int Mass
        {
            get { return mass; }
            set { mass = value; }
        }

        private Vector2 position;
        public Vector2 Position
        {
            get { return position; }
            set { position = value; }
        }

        private Vector2 origin;
        public Vector2 Origin
        {
            get { return origin; }
            set { origin = value; }        
        }

        public Vector2 OffSet { get; set; }

        private Texture2D axisX;
        public Texture2D AxisX
        {
            get { return axisX; }
            set { axisX = value; }
        }

        private Texture2D axisY;
        public Texture2D AxisY
        {
            get { return axisY; }
            set { axisY = value; }
        }

        private Vector2 axisPosition;
        public Vector2 AxisPosition
        {
            get { return axisPosition; }
            set { axisPosition = value; }
        }

        private Vector2 xCoorPosition;
        public Vector2 XCoorPosition
        { 
            get { return xCoorPosition; }
            set { xCoorPosition = value; }
        }

        private double momentOfInertiaCenter;
        public double MomentOfInertiaCenter
        { 
            get { return momentOfInertiaCenter; }
            set { momentOfInertiaCenter = value; }
        }

        private double distance;
        public double Distance
        { 
            get { return distance; }
            set { distance = value; }
        }

        private double momentOfInertiaCOM;
        public double MomentOfInertiaCOM
        {
            get { return momentOfInertiaCOM; }
            set { momentOfInertiaCOM = value; }
        }

        public Object(Vector2 dimension, Vector2 position, int mass, GraphicsDevice graphicDevice)
        {            
            this.dimension = dimension;
            this.position = position;
            this.mass = mass;
            this.graphicDevice = graphicDevice;

            OffSet = new Vector2(450, 450);
            axisX = CreateRectangle((int)Dimension.X,1, Color.White);
            axisY = CreateRectangle((int)Dimension.Y,1 , Color.White);                   
        }

        public Texture2D CreateRectangle(int width, int height, Color objColor)
        {
            Texture2D rectTexture = new Texture2D(graphicDevice, width, height, false, SurfaceFormat.Color);

            Color[] color = new Color[width * height];

            for (int i = 0; i < color.Length; i++)
                color[i] = objColor;

            rectTexture.SetData(color);

            return rectTexture;
        }
    }
}
